<?php
require_once realpath(dirname(__FILE__).'/../../app/init.php');
require_once 'AIR2_DBManager.php';
$profile_name = AIR2_DBManager::init();
echo "Using db $profile_name ...";

/**
 * Uses doctrine to create tables in the database (defined in 
 * 'app/config/databases.php').  Does not check for existing tables, so make 
 * sure you drop them before running this, or you'll get some errors
 */

$models = Doctrine::getLoadedModels();
echo " > Creating ".count($models)." models in the database ....";

try {
    // model path already defined in docrine_pi.php
    $conn = AIR2_DBManager::get_master_connection();
    Doctrine::createTablesFromModels();
    echo "done!\n";
} catch (Doctrine_Exception $e) {
    error_log("Error creating models in database!");
    error_log($e->getMessage());
}


?>
